package oa.hleast.xswl.controller.app.oms;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import oa.hleast.common.result.Result;
import oa.hleast.xswl.pojo.form.OmsOrderRefundForm;
import oa.hleast.xswl.pojo.vo.oms.ShowOmsOrderRefundVo;
import oa.hleast.xswl.service.oms.OmsOrderRefundService;
import org.springframework.web.bind.annotation.*;


@Api(tags = "【移动端】订单退款表")
@RestController("AppOmsOrderRefundController")
@RequestMapping("/api.app/v1/omsOrderRefunds")
@Slf4j
@AllArgsConstructor
public class OmsOrderRefundController {

    private OmsOrderRefundService omsOrderRefundService;


    @ApiOperation(value = "申请退款/退款退货", httpMethod = "POST")
    @PostMapping("/requestRefund")
    public Result<Boolean> requestRefund(@RequestBody OmsOrderRefundForm form) {
        Boolean result = omsOrderRefundService.requestRefund(form);
        return Result.success(result);
    }

    @ApiOperation(value = "重新申请退款/退款退货", httpMethod = "POST")
    @PostMapping("/againRequestRefund")
    public Result<Boolean> againRequestRefund(@RequestBody OmsOrderRefundForm form) {
        Boolean result = omsOrderRefundService.againRequestRefund(form);
        return Result.success(result);
    }

    @ApiOperation(value = "取消退款/退款退货申请", httpMethod = "GET")
    @GetMapping("/cancelRefund")
    public Result<Boolean> cancelRefund(@RequestParam Long orderId, @RequestParam Long orderItemId) {
        Boolean result = omsOrderRefundService.cancelRefund(orderId, orderItemId);
        return Result.success(result);
    }

    @ApiOperation(value = "退款/售后详情", httpMethod = "GET")
    @GetMapping("/getRefundDetails")
    public Result<ShowOmsOrderRefundVo> getRefundDetails(@RequestParam Long orderId, @RequestParam Long orderItemId) {
        ShowOmsOrderRefundVo result = omsOrderRefundService.getRefundDetails(orderId, orderItemId);
        return Result.success(result);
    }

    @ApiOperation(value = "填写退货物流信息", httpMethod = "GET")
    @GetMapping("/saveDeliveryInfo")
    public Result<Boolean> saveDeliveryInfo(@RequestParam Long refundId, @RequestParam String deliveryCompany, @RequestParam String deliverySn) {
        Boolean result = omsOrderRefundService.saveDeliveryInfo(refundId, deliveryCompany, deliverySn);
        return Result.success(result);
    }

}
